﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.Concept
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using System.Xml;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem
{
  public class Concept : MBObjectBase
  {
    internal static void AutoGeneratedStaticCollectObjectsConcept(
      object o,
      List<object> collectedObjects)
    {
      ((MBObjectBase) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    public TextObject Title { get; set; }

    public TextObject Description { get; set; }

    public string FilterGroup { get; set; }

    public string LinkID { get; private set; }

    public static MBReadOnlyList<Concept> All => Campaign.Current.Concepts;

    public string EncyclopediaLink
    {
      get
      {
        return Campaign.Current.EncyclopediaManager.GetIdentifier(typeof (Concept)) + "-" + this.StringId;
      }
    }

    public TextObject EncyclopediaLinkWithName
    {
      get => HyperlinkTexts.GetConceptHyperlinkText(this.EncyclopediaLink, this.Title);
    }

    public override void Deserialize(MBObjectManager objectManager, XmlNode node)
    {
      base.Deserialize(objectManager, node);
      this.Title = new TextObject(node.Attributes["title"].Value);
      this.Description = new TextObject(node.Attributes["text"].Value);
      this.FilterGroup = node.Attributes["group"] != null ? node.Attributes["group"].Value : "";
      this.LinkID = node.Attributes["link_id"].Value;
    }

    public static bool IsGroupMember(string groupName, Concept c) => c.FilterGroup == groupName;

    public static void SetConceptTextLinks()
    {
      foreach (Concept concept in (List<Concept>) Concept.All)
        MBTextManager.SetTextVariable(concept.LinkID, concept.EncyclopediaLinkWithName, false);
    }
  }
}
